<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE TupleSections #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ForeignFunctionInterface #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHCi.StaticPtrTable</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHCi.StaticPtrTable.html#sptAddEntry"><span class="hs-identifier">sptAddEntry</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-comment">-- See note [Why do we import Prelude here?]</span><span>
</span><span id="line-7"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span>
</span><span id="line-8"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-9"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Fingerprint.html#"><span class="hs-identifier">GHC.Fingerprint</span></a></span><span>
</span><span id="line-10"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHCi.RemoteTypes.html"><span class="hs-identifier">GHCi.RemoteTypes</span></a></span><span>
</span><span id="line-11"></span><span>
</span><span id="line-12"></span><span class="hs-comment">-- | Used by GHCi to add an SPT entry for a set of interactive bindings.</span><span>
</span><span id="line-13"></span><span class="annot"><a href="GHCi.StaticPtrTable.html#sptAddEntry"><span class="hs-identifier hs-type">sptAddEntry</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-type">Fingerprint</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHCi.RemoteTypes.html#HValue"><span class="hs-identifier hs-type">HValue</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-14"></span><span id="sptAddEntry"><span class="annot"><span class="annottext">sptAddEntry :: Fingerprint -&gt; HValue -&gt; IO ()
</span><a href="GHCi.StaticPtrTable.html#sptAddEntry"><span class="hs-identifier hs-var hs-var">sptAddEntry</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-type">Fingerprint</span></a></span><span> </span><span id="local-6989586621679087941"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679087941"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679087940"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679087940"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHCi.RemoteTypes.html#HValue"><span class="hs-identifier hs-type">HValue</span></a></span><span> </span><span id="local-6989586621679087938"><span class="annot"><span class="annottext">Any
</span><a href="#local-6989586621679087938"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-comment">-- We own the memory holding the key (fingerprint) which gets inserted into</span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-comment">-- the static pointer table and can't free it until the SPT entry is removed</span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-comment">-- (which is currently never).</span><span>
</span><span id="line-18"></span><span>    </span><span id="local-6989586621679087937"><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679087937"><span class="hs-identifier hs-var">fpr_ptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Word64] -&gt; IO (Ptr Word64)
forall a. Storable a =&gt; [a] -&gt; IO (Ptr a)
</span><a href="../../base/src/Foreign.Marshal.Array.html#newArray"><span class="hs-identifier hs-var">newArray</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679087941"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679087940"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-19"></span><span>    </span><span id="local-6989586621679087935"><span class="annot"><span class="annottext">StablePtr Any
</span><a href="#local-6989586621679087935"><span class="hs-identifier hs-var">sptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Any -&gt; IO (StablePtr Any)
forall a. a -&gt; IO (StablePtr a)
</span><a href="../../base/src/GHC.Stable.html#newStablePtr"><span class="hs-identifier hs-var">newStablePtr</span></a></span><span> </span><span class="annot"><span class="annottext">Any
</span><a href="#local-6989586621679087938"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-20"></span><span>    </span><span id="local-6989586621679087934"><span class="annot"><span class="annottext">Ptr (Ptr ())
</span><a href="#local-6989586621679087934"><span class="hs-identifier hs-var">ent_ptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO (Ptr (Ptr ()))
forall a. Storable a =&gt; IO (Ptr a)
</span><a href="../../base/src/Foreign.Marshal.Alloc.html#malloc"><span class="hs-identifier hs-var">malloc</span></a></span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><span class="annottext">Ptr (Ptr ()) -&gt; Ptr () -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr ())
</span><a href="#local-6989586621679087934"><span class="hs-identifier hs-var">ent_ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StablePtr Any -&gt; Ptr ()
forall a. StablePtr a -&gt; Ptr ()
</span><a href="../../base/src/GHC.Stable.html#castStablePtrToPtr"><span class="hs-identifier hs-var">castStablePtrToPtr</span></a></span><span> </span><span class="annot"><span class="annottext">StablePtr Any
</span><a href="#local-6989586621679087935"><span class="hs-identifier hs-var">sptr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span>    </span><span class="annot"><span class="annottext">Ptr Word64 -&gt; Ptr (Ptr ()) -&gt; IO ()
</span><a href="GHCi.StaticPtrTable.html#spt_insert_stableptr"><span class="hs-identifier hs-var">spt_insert_stableptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679087937"><span class="hs-identifier hs-var">fpr_ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr ())
</span><a href="#local-6989586621679087934"><span class="hs-identifier hs-var">ent_ptr</span></a></span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-string">&quot;hs_spt_insert_stableptr&quot;</span></span><span>
</span><span id="line-25"></span><span>    </span><span id="spt_insert_stableptr"><span class="annot"><a href="GHCi.StaticPtrTable.html#spt_insert_stableptr"><span class="hs-identifier hs-var">spt_insert_stableptr</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-26"></span></pre></body></html>